package com.ewzj.bigdata.mvp.model

import com.ewzj.bigdata.app.config.netmodel.CommonService
import com.ewzj.bigdata.app.utils.Apputils
import com.ewzj.bigdata.mvp.contract.HourseListContract
import com.ewzj.bigdata.mvp.model.reqbean.ReqSubBean
import com.ewzj.bigdata.mvp.model.reqbean.Reqpagebean
import com.ewzj.bigdata.mvp.model.rspbean.BaseData
import com.ewzj.bigdata.mvp.model.rspbean.BaseListData
import com.ewzj.bigdata.mvp.model.rspbean.HomeBean
import com.ewzj.bigdata.mvp.model.rspbean.SubFilterBean
import com.google.gson.Gson
import com.jess.arms.integration.IRepositoryManager
import com.jess.arms.mvp.BaseModel
import io.reactivex.Observable
import javax.inject.Inject

/**
 * author:zhangjing
 * 作用:
 * return:
 */
class HourseListModel @Inject constructor(val mGson:Gson,repositoryManager: IRepositoryManager):BaseModel(repositoryManager),HourseListContract.Model{


    val service=repositoryManager.obtainRetrofitService(CommonService::class.java)

    override fun loadHouses(groupId: String?, words: String,page: Int,areaid:String): Observable<BaseData<BaseListData<HomeBean>>> {
        val pagebean :Reqpagebean=Reqpagebean()
        if (groupId!=null) pagebean.groupId=groupId
        pagebean.areaId =areaid
        pagebean.words=words
        pagebean.p=page
        return service.allsearch(Apputils.Utils.json2Requestbody(mGson.toJson(pagebean)))
    }
    override fun loadFilter(type: String): Observable<SubFilterBean> {
        val reqSubBean=ReqSubBean(type)
        return service.subFilterlist(Apputils.Utils.json2Requestbody(mGson.toJson(reqSubBean)))
    }


}